package mammuthus.template

import mammuthus.protocal.WriteFileTaskResponse
import mammuthus.master.Master
import mammuthus.tool.TemplateTool

/**
 * 5/3/15 WilliamZhu(allwefantasy@gmail.com)
 */
class DefaultProcessor(master: Master) extends TemplateProcessor {
  override def process(fileName: String, targetFilePath: String, params: Map[String, AnyRef]): List[WriteFileTaskResponse] = {
    val appName = params("appName")
    val hostNames = params("slaves").asInstanceOf[String]
    val configStr = TemplateTool.render(s"/template/app/$appName/$fileName", params)
    master.writeFile(hostNames, configStr, s"$targetFilePath", false).toList
  }
}
